import { sveltekit } from '@sveltejs/kit/vite';
// import autoImport from 'sveltekit-autoimport';
import Unocss from 'unocss/vite';
// import wasmPack from 'vite-plugin-wasm-pack';

/** @type {import('vite').UserConfig} */

const config = {
	server: {
		// headers: {
		// 	'Cross-Origin-Embedder-Policy': 'require-corp',
		// 	'Cross-Origin-Opener-Policy': 'same-origin',
		// },
		proxy: {
			"/socket.io": {
				ws: true,
				changeOrigin: true,//允许跨域
				target: "ws://localhost:8080/socket.io"
			}
		}
	},
	plugins: [
		Unocss(),
		// autoImport({
		// 	components: [{ name: './src/lib', flat: true }],
		// 	// some frequently used modules
		// 	module: {
		// 		svelte: ['onMount', 'createEventDispatcher']
		// 	},

		// 	// manually import
		// 	mapping: {
		// 		API: `import API from '~/src/api'`,
		// 		Icon: `import * as Icon from '$components/icon'`,
		// 	},

		// 	// autoimport only for .svelte files
		// 	// and only search for .svelte files inside components
		// 	include: ['**/*.(md|svelte)'],

		// 	// node_modules is ignored by default
		// 	exclude: ['**/node_modules/**'],
		// }),
		sveltekit(),
		// wasmPack('./wasm')
	],
	// ssr: {
	// 	noExternal: ['three', 'troika-three-text']
	// },
	test: {
		include: ['src/**/*.{test,spec}.{js,ts}']
	}
};

export default config;
